/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PaymentDialog.java
 *
 * Created on 23.Kas.2009, 22:58:21
 */

package edu.iyte.ceng431.hw2.pos.view;

import java.awt.event.ActionListener;

/**
 *
 * @author $@D!$t
 */
public class PaymentDialog extends javax.swing.JDialog {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private double total = 0;
    /** Creates new form PaymentDialog */
    public PaymentDialog(java.awt.Frame parent, boolean modal, double total) {
        super(parent, modal);
        this.total = total;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */ 
    private void initComponents() {

        cashLabel = new javax.swing.JLabel();
        cashTextField = new javax.swing.JTextField();
        cerditCardLabel = new javax.swing.JLabel();
        creditCardTextField = new javax.swing.JTextField();
        creditCardNumberLabel = new javax.swing.JLabel();
        creditCardNumberTextField = new javax.swing.JTextField();
        payButton = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(255, 220));

        cashLabel.setText("Cash Payment Amount");

        cashTextField.setText(String.valueOf(this.total));

        cerditCardLabel.setText("Credit Card Payment Amount");

        creditCardTextField.setText("0");

        creditCardNumberLabel.setText("Credit Card Number");

        payButton.setText("PAY");

        cancelButton.setText("CANCEL");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(51, 51, 51)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(payButton)
                        .addGap(18, 18, 18)
                        .addComponent(cancelButton, javax.swing.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE))
                    .addComponent(cashLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                    .addComponent(cashTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                    .addComponent(cerditCardLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(creditCardTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                    .addComponent(creditCardNumberLabel)
                    .addComponent(creditCardNumberTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE))
                .addGap(50, 50, 50))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cashLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cashTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cerditCardLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(creditCardTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(creditCardNumberLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(creditCardNumberTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cancelButton)
                    .addComponent(payButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancelButton;
    private javax.swing.JLabel cashLabel;
    private javax.swing.JTextField cashTextField;
    private javax.swing.JLabel cerditCardLabel;
    private javax.swing.JLabel creditCardNumberLabel;
    private javax.swing.JTextField creditCardNumberTextField;
    private javax.swing.JTextField creditCardTextField;
    private javax.swing.JButton payButton;
    // End of variables declaration//GEN-END:variables
    
    public javax.swing.JLabel getCreditCardNumberLabel() {
		return creditCardNumberLabel;
	}

    /**
     * @return the creditCardTextField
     */
    public javax.swing.JTextField getCreditCardTextField() {
        return creditCardTextField;
    }

    /**
     * @param creditCardTextField the creditCardTextField to set
     */
    public void setCreditCardTextField(javax.swing.JTextField creditCardTextField) {
        this.setCreditCardTextField(creditCardTextField);
    }

    /**
     * @return the creditCardNumberTextField
     */
    public javax.swing.JTextField getCreditCardNumberTextField() {
        return creditCardNumberTextField;
    }

    /**
     * @param creditCardNumberTextField the creditCardNumberTextField to set
     */
    public void setCreditCardNumberTextField(javax.swing.JTextField creditCardNumberTextField) {
        this.creditCardNumberTextField = creditCardNumberTextField;
    }

    /**
     * @return the cashTextField
     */
    public javax.swing.JTextField getCashTextField() {
        return cashTextField;
    }

    /**
     * @param cashTextField the cashTextField to set
     */
    public void setCashTextField(javax.swing.JTextField cashTextField) {
        this.cashTextField = cashTextField;
    }
    
    public void addPayListener(ActionListener pay) {
    	payButton.addActionListener (pay);
    }
    
    public void addCancelListener(ActionListener cancel) {
    	cancelButton.addActionListener(cancel);
    }
    
    public void addCashTextListener(ActionListener cash) {
    	cashTextField.addActionListener(cash);
    }
    
    public void addCreditTextListener(ActionListener credit) {
    	creditCardTextField.addActionListener(credit);
    }

}
